<extend name="Layout/application"/>

<block name="content">
    <div class="row">
        <div class="col-md-12">

            <div class="row">
                <div class="col-md-8">
                    <div class="page-header">
                        <h1>文章列表</h1>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-10">
                    <div class="panel panel-default">
                        <div class="panel-heading">文章列表</div>

                        <div class="panel-body">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th class="col-md-1"><input type="checkbox" id="all_check"></th>
                                    <th class="col-md-3">标题</th>
                                    <th class="col-md-2">栏目</th>
                                    <th class="col-md-3">发布时间</th>
                                    <th class="col-md-1">操作</th>
                                </tr>
                                </thead>
                                    <form action="" id="form" method="post">
                                        <tbody>
                                            <volist name="list" id="a">
                                            <tr>
                                                <td class="col-md-1"><input type="checkbox" class="check" name="delete_id[]" value="{{$a.id}}"></td>
                                                <td class="col-md-3">{{$a.title}}</td>
                                                <td class="col-md-2">{{$a.category.name}}</td>
                                                <td class="col-md-3">{{$a.time|date="Y-m-d H:i:s",###}}</td>
                                                <td class="col-md-1">
                                                    <a href="{{:U('edit_article',array('id'=>$a['id']))}}"  >
                                                    <span class="glyphicon glyphicon-pencil"></span>
                                                    </a>
                                                    <a href="{{:U('destroy_article',array('id'=>$a['id']))}}">
                                                        <span class="glyphicon glyphicon-trash"></span>
                                                    </a>
                                                </td>
                                            </tr>
                                            </volist>
                                        </tbody>
                                    </form>
                            </table>
                            <div class="result page col-md-offset-4">{{$page}}</div>
                        </div>

                    </div>
                </div>


                <div class="col-md-2">
                    <div class="list-group">
                        <a href="{{:U('create_article')}} " class="list-group-item list-group-item-info sort_category" >
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 新增 (add)
                        </a>
                        <a href="javascript: void 0;" class="list-group-item list-group-item-info sort_category" id="destroy_checked">
                            <span class="glyphicon glyphicon-trash" aria-hidden="true"></span> 删除 (del)
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="js">
    <script>
        $(function () {
            $('#all_check').click(function () {
                $('.check').prop('checked',this.checked);
            })

            $('#destroy_checked').click(function () {
                var length = $('.check:checked').length;
                if(length == 0){
                    alert('你必须选中一条');
                    return false;
                }
                $('#form').attr('action',"{{:U('destroy_checked')}}").submit();

            })
        })

    </script>
</block>